function Personal(){
    this.users = null;
    this.data = null;
    this.cart = null;


    this.getData = function(){
        var scope = this;
        if(!scope.data){
            scope.data = $.ajax({

                type:'POST',
                url:'personal.php',
                data: 'login='+login+'&pass='+pass,
                async: false,
                success: function (data){
                }
            }).responseText;
            //alert(scope.data);
            return scope.data;
        }else{
            return scope.data;
        }
    };

    this.parseData = function(){
        var scope = this;
       var userText="", cart, phone3;
        cart = JSON.parse(this.getData());
        cart;
        cart.length;
        scope.cart = cart;
        userText='<table >';

            for(var i=0; i<cart.length; i++){
                phone3="phone3";

                userText+='<tr>'+
                    '<td style="width: 30px">'+(i+1)+
                    '</td><td style="width: 130px">'+
                    cart[i]['user']+
                    ' </td><td class="check"> '+
                    '<input type="checkbox" name="is_alert" '+ (cart[i]['is_alert'] ==1 ? 'checked="checked"':'') +'onchange = "loadPersonal.eventChecked(this,'+i+')" >'+
                    '</td><td  class="check">'+
                    '<input type="checkbox" name="is_alert1"'+ (cart[i]['is_alert1'] ==1 ? 'checked="checked"':'') +'onchange = "loadPersonal.eventChecked(this,'+i+')" >'+
                    '</td><td  class="check">'+
                    '<input type="checkbox"  name="is_alert2"'+ (cart[i]['is_alert2'] ==1 ? 'checked="checked"':'') +'onchange = "loadPersonal.eventChecked(this,'+i+')" >'+
                    '</td><td  class="check">'+
                    '<input type="checkbox" name="is_alert3" '+ (cart[i]['is_alert3'] ==1 ? 'checked="checked"':'') +' onchange = "loadPersonal.eventChecked(this,'+i+')" >'+
                    '</td><td  class="check">'+
                    '<input type="checkbox" name="is_alert4" '+ (cart[i]['is_alert4'] ==1 ? 'checked="checked"':'') +' onchange = "loadPersonal.eventChecked(this,'+i+')" >'+

                    '</td>'
                '</tr>';
            }


        userText+='</table>';
            document.getElementById('table_personal').innerHTML = userText;

      //  $('#table_personal').css("background-color",'red');
        scrollbar4.tinyscrollbar_update();
    }

    this.alertMsg = function(){
        var scope = this;


        alert( JSON.stringify(scope.cart));
    }
//меняет исходный закаченый объект
    this.eventChecked = function(obj, i){
        var scope = this;
        obj.name;
        scope.cart[i][obj.name]= (obj.checked ? 1: 0);
        scope.cart;
    };


    this.parseData();
}
loadPersonal = new Personal();

